home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / opcode.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  3.5 KB  |  130 lines

  1. #ifndef Py_OPCODE_H
  2. #define Py_OPCODE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Instruction opcodes for compiled code */
  8.  
  9. #define STOP_CODE    0
  10. #define POP_TOP        1
  11. #define ROT_TWO        2
  12. #define ROT_THREE    3
  13. #define DUP_TOP        4
  14.  
  15. #define UNARY_POSITIVE    10
  16. #define UNARY_NEGATIVE    11
  17. #define UNARY_NOT    12
  18. #define UNARY_CONVERT    13
  19.  
  20. #define UNARY_INVERT    15
  21.  
  22. #define BINARY_POWER    19
  23.  
  24. #define BINARY_MULTIPLY    20
  25. #define BINARY_DIVIDE    21
  26. #define BINARY_MODULO    22
  27. #define BINARY_ADD    23
  28. #define BINARY_SUBTRACT    24
  29. #define BINARY_SUBSCR    25
  30.  
  31. #define SLICE        30
  32. /* Also uses 31-33 */
  33.  
  34. #define STORE_SLICE    40
  35. /* Also uses 41-43 */
  36.  
  37. #define DELETE_SLICE    50
  38. /* Also uses 51-53 */
  39.  
  40. #define STORE_SUBSCR    60
  41. #define DELETE_SUBSCR    61
  42.  
  43. #define BINARY_LSHIFT    62
  44. #define BINARY_RSHIFT    63
  45. #define BINARY_AND    64
  46. #define BINARY_XOR    65
  47. #define BINARY_OR    66
  48.  
  49.  
  50. #define PRINT_EXPR    70
  51. #define PRINT_ITEM    71
  52. #define PRINT_NEWLINE    72
  53.  
  54. #define BREAK_LOOP    80
  55.  
  56. #define LOAD_LOCALS    82
  57. #define RETURN_VALUE    83
  58.  
  59. #define EXEC_STMT    85
  60.  
  61. #define POP_BLOCK    87
  62. #define END_FINALLY    88
  63. #define BUILD_CLASS    89
  64.  
  65. #define HAVE_ARGUMENT    90    /* Opcodes from here have an argument: */
  66.  
  67. #define STORE_NAME    90    /* Index in name list */
  68. #define DELETE_NAME    91    /* "" */
  69. #define UNPACK_TUPLE    92    /* Number of tuple items */
  70. #define UNPACK_LIST    93    /* Number of list items */
  71. #define STORE_ATTR    95    /* Index in name list */
  72. #define DELETE_ATTR    96    /* "" */
  73. #define STORE_GLOBAL    97    /* "" */
  74. #define DELETE_GLOBAL    98    /* "" */
  75.  
  76. #define LOAD_CONST    100    /* Index in const list */
  77. #define LOAD_NAME    101    /* Index in name list */
  78. #define BUILD_TUPLE    102    /* Number of tuple items */
  79. #define BUILD_LIST    103    /* Number of list items */
  80. #define BUILD_MAP    104    /* Always zero for now */
  81. #define LOAD_ATTR    105    /* Index in name list */
  82. #define COMPARE_OP    106    /* Comparison operator */
  83. #define IMPORT_NAME    107    /* Index in name list */
  84. #define IMPORT_FROM    108    /* Index in name list */
  85.  
  86. #define JUMP_FORWARD    110    /* Number of bytes to skip */
  87. #define JUMP_IF_FALSE    111    /* "" */
  88. #define JUMP_IF_TRUE    112    /* "" */
  89. #define JUMP_ABSOLUTE    113    /* Target byte offset from beginning of code */
  90. #define FOR_LOOP    114    /* Number of bytes to skip */
  91.  
  92. #define LOAD_GLOBAL    116    /* Index in name list */
  93.  
  94. #define SETUP_LOOP    120    /* Target address (absolute) */
  95. #define SETUP_EXCEPT    121    /* "" */
  96. #define SETUP_FINALLY    122    /* "" */
  97.  
  98. #define LOAD_FAST    124    /* Local variable number */
  99. #define STORE_FAST    125    /* Local variable number */
  100. #define DELETE_FAST    126    /* Local variable number */
  101.  
  102. #define SET_LINENO    127    /* Current line number */
  103.  
  104. /* It used to be the case that opcodes should fit in 7 bits.  This is
  105.    no longer the case -- 8 bits is fine (the instruction stream is now
  106.    a sequence of unsigned characters).  We gladly use the new space
  107.    for new opcodes. */
  108.  
  109. #define RAISE_VARARGS    130    /* Number of raise arguments (1, 2 or 3) */
  110. /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
  111. #define CALL_FUNCTION    131    /* #args + (#kwargs<<8) */
  112. #define MAKE_FUNCTION    132    /* #defaults */
  113. #define BUILD_SLICE     133    /* Number of items */
  114.  
  115. /* The next 3 opcodes must be contiguous and satisfy
  116.    (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1  */
  117. #define CALL_FUNCTION_VAR          140    /* #args + (#kwargs<<8) */
  118. #define CALL_FUNCTION_KW           141    /* #args + (#kwargs<<8) */
  119. #define CALL_FUNCTION_VAR_KW       142    /* #args + (#kwargs<<8) */
  120.  
  121. /* Comparison operator codes (argument to COMPARE_OP) */
  122. enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
  123.  
  124. #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
  125.  
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif /* !Py_OPCODE_H */
  130.